package lab_11.com.acme.bankapp.domain.bank;


public class SavingsAccount extends AbstractAccount {

	public SavingsAccount(double balance) {
		super(balance);
	}

	@Override
	public void withdraw(double amount) throws IllegalArgumentException {
		if (amount > 0) {
			balance -= amount;
		} else {
			throw new IllegalArgumentException();
		}
	}

	@Override
	public double maximumAmountToWithdraw() {
		return (balance >= 0) ? balance : 0;
	}

	@Override
	public void printAllAccountData() {
		System.out.println("Savings account.");
		System.out.format("Balance: %1$f\n", balance);
		System.out.format("Maximum amount to withdraw: %1$f\n",
				maximumAmountToWithdraw());
	}
}
